require 'View/UIBase/UIBase'
require "Common/define"
require "Logic/Config"
require "Common/functions"
local UIGuildPanelSkin = require "View/UIGuild/Skin/UIGuildPanelSkin"

UIGuildPanel = UIBase.New(PanelNames.UIGuildPanel);

function UIGuildPanel.Init(func)
    UIBase.Init(UIGuildPanel, func);
end

---@param obj GComponent
function UIGuildPanel:OnCreate()
    self.viewSkin = UIGuildPanelSkin.New(self.fguiObj);
    self.viewSkin:setCloseCallback(function() self:OnBack() end);
    self:RegisterEvent(Config.EventType.Union_Quit_S2C,self.respUnionQuit);
end

function UIGuildPanel:OnBack()
    if logicMgr.GuildManager.unionInfo and not getUI(PanelResNames.UIGuild) then
        showUI(PanelNames.UIGuild);
    end
    DestoryUI(PanelNames.UIGuildPanel)
end

function UIGuildPanel:OnDestroy()
    self.viewSkin:OnDestroy();
end

function UIGuildPanel:respUnionQuit()
    DestoryUI(PanelNames.UIGuildSetting);
    DestoryUI(PanelNames.UIGuildPanel);
    DestoryUI(PanelNames.UIGuild);
end

return UIGuildPanel;